<?php
namespace app\admin\controller;

use app\common\controller\AdminBase;
use app\common\model\PlayerRole as PlayerRoleModel;
use think\Db;

/**
 * 玩家管理
 * Class AdminUser
 * @package app\admin\controller
 */
class PlayerRole extends AdminBase
{
    
    protected function _initialize()
    {
        parent::_initialize();
    }

    /**
     * 角色管理
     * @param string $keyword
     * @param int    $page
     * @return mixed
     */
    public function index($page = 1)
    {
        $map  = [];
        $data = input();
        if (!empty($data['name'])) {
            $map[] = ['role_name','like', "%{$data['name']}%"];
        }

        if (!empty($data['game'])) {
            $map[] = ['gid', '=', $data['game']];
        }
        if (!empty($data['cid']) && $data['cid'] != 0) {
            $map[] = ['cid','=', $data['cid']];
        }
        if (!empty($data['uid']) && $data['uid'] != 0) {
            $map[] = ['uid','=', $data['uid']];
        }

        $game_list = PlayerRoleModel::get_list($map, 'id DESC', $page);
        return $this->fetch('index', ['game_list' => $game_list,'reg_list' => $game_list,'data' => $data]);
    }
}